package main

import (
	"01/models"
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

func main() {
	dsn := "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Println("数据库链接失败")
		return
	}
	err = db.AutoMigrate(
		&models.Article{},
	)
	if err != nil {
		fmt.Println("迁移失败")
		return
	}
}
